package com.sunjian.controller;

import com.sunjian.dto.ApiResult;
import com.sunjian.entity.House;
import com.sunjian.entity.User;
import com.sunjian.service.HouseService;
import com.sunjian.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author sunjian
 * @date 2021/12/2 22:18
 */
@RequestMapping("/api/user")
@RestController
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;
    @Autowired
    private HouseService houseService;

    @GetMapping("/getAllUserInfo")
    public ApiResult getAllUserInfo(){
        List<User> data = userService.queryALLUser();
        List<House> data2 = houseService.queryAllHouse();
        ApiResult apiResult = new ApiResult();
        apiResult.setCode(200);
        apiResult.setMsg("操作成功");
        apiResult.setData(data);
        log.info("--------------------------------------");
        log.info("获取所有的用户信息：{}", data.toString());
        log.info("获取所有的House信息：{}", data2.toString());
        return apiResult;
    }
}
